package com.wxx.design.composite;

import java.util.ArrayList;
import java.util.List;

/**
 * @author Jetwang
 * @version 1.0
 * @date 2022/4/21 20:39
 */
public class CourseCatalog extends CatalogComponent{
    private List<CatalogComponent> items = new ArrayList<>();
    private String name;

    public CourseCatalog(String name) {
        this.name = name;
    }

    @Override
    public String getName(CatalogComponent catalogComponent) {
        return this.name;
    }

    @Override
    public void add(CatalogComponent catalogComponent) {
        items.add(catalogComponent);
    }

    @Override
    public void remove(CatalogComponent catalogComponent) {
        items.remove(catalogComponent);
    }

    @Override
    public void Print() {
        System.out.println(name);
        for (CatalogComponent item : items) {
            item.Print();
        }
    }
}
